package com.cl.master.controller;

import com.cl.master.common.Result;
import com.cl.master.domain.SewageStandard;
import com.cl.master.domain.WaterQuality;
import com.cl.master.mapper.WaterQualityMapper;
import com.cl.master.service.impl.SewageStandardServiceImpl;
import com.cl.master.service.impl.waterQualityServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @Author xc
 * @Date 2023/4/26 16:17
 * @Version 1.0
 */
@RestController//=@Controller+@ResponseBody表示该类是springboot的一个controller，且返回的数据为JSON格式
// @Component
@RequestMapping("sewage")
public class WaterQualityController {


    @Resource
    private waterQualityServiceImpl waterQualityService ;


//以下为地下水水质信息的响应

    // @GetMapping("/waterpage/{startPage}")
    // public String getSewage(Model model, @PathVariable(value = "startPage") int startPage){
    //     Collection<WaterQuality> allInfoByCode = waterQualityService.getAllInfo(startPage);
    //     System.out.println(startPage);
    //     model.addAttribute("allInfoByCode",allInfoByCode);
    //     model.addAttribute("startPage",startPage);
    //     return "manage/waterQuality";
    // }


    //获得相关所有的数据信息
    @RequestMapping("getAllWaterInfo")
    public Result getAllWaterInfo(){
        List<Map<String,Object>> data = waterQualityService.getAllWaterInfo();
        Result result = Result.success(data);
        return result;
    }

    //删除操作
    @PostMapping("/deleteWaterInfo")
    public void deleteWaterInfo(@RequestParam Long id) {
        waterQualityService.deleteWaterInfo(id);
    }

//以下为数据可视化处理的响应

    @RequestMapping("getDataByMid")
    public Result getDataByMid(){
        System.out.println("接收前端发起的JSON数据请求，后续需要查询mysql将数据返回");
        // String datetime = FastDateFormat.getInstance("yyyy-MM-dd").format(System.currentTimeMillis());
        int Mid = 22;

        Map<String, Object> data = waterQualityService.getDataByMid(Mid);

        Result result = Result.success(data);
        return result;
    }


    //获取溶解氧不达标数量
    @RequestMapping("getCountBy")
    public Result getCountBy(){
        Map<String,Object> data = waterQualityService.getCount();
        Result result = Result.success(data);
        return result;
    }

    //获取site_condition = '正常'数据(站点正常)
    @RequestMapping("getStatusBy")
    public Result getStatusBy(){
        Map<String,Object> data = waterQualityService.getStatusBy();
        Result result = Result.success(data);
        return result;
    }

    //获取turbidity <= 20 (排污浊度达标)
    @RequestMapping("getStandardBy")
    public Result getStandardBy(){
        Map<String,Object> data = waterQualityService.getStandardBy();
        Result result = Result.success(data);
        return result;
    }

    //获取平均ph值
    @RequestMapping("getPHBy")
    public Result getPHBy(){
        Map<String,Object> data = waterQualityService.getPHBy();
        Result result = Result.success(data);
        return result;
    }

    //获取正常达标数据
    @RequestMapping("getNormalBy")
    public Result getNormalBy(){
        Map<String,Object> data = waterQualityService.getNormalBy();
        Result result = Result.success(data);
        return result;
    }

    //动态信息溶解氧与浊度信息
    @RequestMapping("getDissolvedOxygenAndTurbidity")
    public Result getDissolvedOxygenAndTurbidity(){
        List<Map<String,Object>> data = waterQualityService.getDissolvedOxygenAndTurbidity();
        Result result = Result.success(data);
        return result;
    }

    //暂无
    @RequestMapping("getCityAndWatershedBy")
    public Result getCityAndWatershedBy(){
        Map<String,Object> data = waterQualityService.getCityAndWatershedBy();
        Result result = Result.success(data);
        return result;
    }

    //获取来源不同市数据和地址信息
    @RequestMapping("getProvinceCityCount")
    public Result getProvinceCityCount(){
        List<Map<String,Object>> data = waterQualityService.getProvinceCityCount();
        Result result = Result.success(data);
        return result;
    }

    //获取不同排污流域数据和地址信息
    @RequestMapping("getWatershedCount")
    public Result getWatershedCount(){
        List<Map<String,Object>> data = waterQualityService.getWatershedCount();
        Result result = Result.success(data);
        return result;
    }


    //获得监测点数据和水温等信息
    @RequestMapping("getWaterQualityData")
    public Result getWaterQualityData(){
        List<Map<String,Object>> data = waterQualityService.getWaterQualityData();
        Result result = Result.success(data);
        return result;
    }

    //获取总磷数据
    @RequestMapping("getPhosphorusData")
    public Result getPhosphorusData(){
        List<Map<String,Object>> data = waterQualityService.getPhosphorusData();
        Result result = Result.success(data);
        return result;
    }

}
